import {WL} from './weilapb'; // 导入 WL 对象
import {WLBuildMsgRet} from './weilapb_wrapper_data';
import {BuildWeilaMsg} from './weilapb_wrapper';
import Long from 'long';

class WeilaPbFriendWrapper {
    public static buildGetFriendInfoReq(latestUpdated: number): WLBuildMsgRet {
        const friendMessage = new WL.Friend.FriendMessage();
        friendMessage.reqGetFriendInfo = new WL.Friend.ReqGetFriendInfo();
        friendMessage.reqGetFriendInfo.latestUpdated = Long.fromValue(latestUpdated);
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_FRIEND,
            WL.Friend.FriendCommandId.FRIEND_COMMAND_GET_FRIENDINFO,
            WL.Service.CommandType.COMMAND_REQUEST, friendMessage);
    }

    public static buildGetFriendUserInfoReq(userIds: number[]): WLBuildMsgRet { 
        const friendMessage = new WL.Friend.FriendMessage();
        friendMessage.reqGetFriendUserInfo = new WL.Friend.ReqGetFriendUserInfo();
        friendMessage.reqGetFriendUserInfo.userIds = userIds;
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_FRIEND,
            WL.Friend.FriendCommandId.FRIEND_COMMAND_GET_FRIEND_USERINFO,
            WL.Service.CommandType.COMMAND_REQUEST, friendMessage);
    }

    public static buildGetFriendInviteInfoReq(latestUpdated: number): WLBuildMsgRet {
        const friendMessage = new WL.Friend.FriendMessage();
        friendMessage.reqGetFriendInviteInfo = new WL.Friend.ReqGetFriendInviteInfo();
        friendMessage.reqGetFriendInviteInfo.latestUpdated = Long.fromValue(latestUpdated);
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_FRIEND,
            WL.Friend.FriendCommandId.FRIEND_COMMAND_GET_FRIEND_INVITEINFO,
            WL.Service.CommandType.COMMAND_REQUEST, friendMessage);
    }

    public static buildGetFriendBlackListReq(pageIndex: number, pageSize: number): WLBuildMsgRet {
        const friendMessage = new WL.Friend.FriendMessage();
        friendMessage.reqGetFriendBlackList = new WL.Friend.ReqGetFriendBlackList();
        friendMessage.reqGetFriendBlackList.pageIndex = pageIndex;
        friendMessage.reqGetFriendBlackList.pageSize = pageSize;
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_FRIEND,
            WL.Friend.FriendCommandId.FRIEND_COMMAND_GET_BLACKLIST,
            WL.Service.CommandType.COMMAND_REQUEST, friendMessage);
    }

    public static buildGetOnlineFriendReq(): WLBuildMsgRet {
        const friendMessage = new WL.Friend.FriendMessage();
        friendMessage.reqGetOnlineFriend = new WL.Friend.ReqGetOnlineFriend();
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_FRIEND,
            WL.Friend.FriendCommandId.FRIEND_COMMAND_GET_ONLINE_FRIEND,
            WL.Service.CommandType.COMMAND_REQUEST, friendMessage);
    }
}

export {WeilaPbFriendWrapper}